<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件详情</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="assets/css/styles.css">
    <!-- 谷歌字体 -->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
    <!-- 引入Quill CSS -->
    <link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
    <style>
        /* 基础样式 */
        body {
            font-family: 'Poppins', sans-serif;
            background-color: #F5F5F5;
            margin: 0;
            padding: 20px;
        }
        .content {
            display: flex;
            flex-wrap: wrap; /* 允许内容换行 */
            justify-content: space-between;
            max-width: 1200px;
            margin: 40px auto;
            background-color: #FFF;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        .left-panel, .right-panel {
            flex: 1 100%; /* 在小屏幕上占满宽度 */
            margin: 0 20px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        h1, .editor-title {
            color: #0C5DF4;
            text-align: center;
            margin-bottom: 20px;
        }
        .form-group {
            margin-bottom: 15px;
            text-align: center;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input[type="text"],
        .form-group select,
        .form-group input[type="date"],
        .form-group input[type="datetime-local"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .back-button {
            background-color: #ccc;
            color: #FFF;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
            margin-right: 10px;
        }
        .back-button:hover {
            background-color: #aaa;
        }
        /* 富文本编辑器样式 */
        #editor-container {
            flex: 1;
            height: 400px;
            border: 1px solid #ddd;
            border-radius: 4px;
            padding: 10px;
            min-height: 300px; /* 保持最小高度 */
        }
        /* 操作按钮容器 */
        .action-buttons {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-top: 20px;
        }
        @media (min-width: 768px) {
            .left-panel, .right-panel {
                flex: 1; /* 在大屏幕上平分宽度 */
            }
        }
    </style>
</head>
<body>
<div class="content">
    <div class="left-panel">
        <div class="form-group">
            <h1>事件详情</h1>
            <form>
                <div class="form-group">
                    <label for="title">事件标题:</label>
                    <input type="text" id="title" name="title" value="${event.title}" readonly>
                </div>
                <div class="form-group">
                    <label for="category">分类:</label>
                    <select id="category" name="categoryId" disabled>
                        <c:forEach items="${categoryList}" var="category">
                            <option value="${category.categoryId}" ${event.categoryId == category.categoryId ? 'selected' : ''}>${category.categoryName}</option>
                        </c:forEach>
                    </select>
                </div>
                <div class="form-group">
                    <label for="priority">优先级:</label>
                    <select id="priority" name="priority" disabled>
                        <option value="0" ${event.priority == 0 ? 'selected' : ''}>重要</option>
                        <option value="1" ${event.priority == 1 ? 'selected' : ''}>紧急</option>
                        <option value="2" ${event.priority == 2 ? 'selected' : ''}>一般</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="startDate">起始时间:</label>
                    <input type="datetime-local" id="startDate" name="startDate" value="<fmt:formatDate value='${event.startDate}' pattern='yyyy-MM-dd\'T\'HH:mm'/>" readonly>
                </div>
                <div class="form-group">
                    <label for="endDate">截止日期:</label>
                    <input type="datetime-local" id="endDate" name="endDate" value="<fmt:formatDate value='${event.endDate}' pattern='yyyy-MM-dd\'T\'HH:mm'/>" readonly>
                </div>
                <div class="form-group">
                    <label for="status">完成状态:</label>
                    <select id="status" name="status" disabled>
                        <option value="0" ${event.status == 0 ? 'selected' : ''}>已完成</option>
                        <option value="1" ${event.status == 1 ? 'selected' : ''}>未完成</option>
                        <option value="2" ${event.status == 2 ? 'selected' : ''}>作废</option>
                    </select>
                </div>
                <div class="action-buttons">
                    <a href="${pageContext.request.contextPath}/user/event" class="back-button">返回事件列表</a>
                </div>
            </form>
        </div>
    </div>
    <div class="right-panel">
        <div class="editor-title">事件描述</div>
        <!-- 富文本编辑器容器 -->
        <div id="editor-container" readonly>${event.description}</div>
    </div>
</div>

<!-- 引入Quill JS -->
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script>
    var quill = new Quill('#editor-container', {
        theme: 'snow',
        readOnly: true
    });
    quill.root.innerHTML = '${event.description}';
</script>
</body>
</html>